# 导入库函数
import requests
import json

from config import config_run

config = config_run()
APIKEY = config[0]
device_id = config[1]
datastream_id = config[2]

# 此处输入APIKEY
# APIKEY = 'xxxxxxxxxxx'

# 此处device_ID替换为自己的设备ID，datastream_id替换为自己的数据流名称
url = ('http://api.heclouds.com/devices/' + device_id + '/datastreams/Lum')

# 请求报文头部
headers = {
    "api-key": APIKEY
}

# 请求报文主体，更新的参数内容
dict = {
    "unit": "KO",
    "unit_symbol": "K"
}

# JSON格式编码
s = json.dumps(dict)

# PUT请求方式，请求服务器更新数据流信息
response = requests.put(url, headers=headers, data=s)

# OneNET返回信息
print(response.headers)
print('1', 20 * '*')
print(response.text)
print('2', 20 * '*')
